import db from '@dfeidao/atom-nodejs/db';
import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import { systemid } from '../atom/config';
interface Message {
	leave_num: string;
	productid: string;
	leave_content: string;
	reviewer: string;
}

interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string;
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin path:app-approval-details/s002,action_id:' + action_id);

	log('Service end path:app-approval-details/s002,action_id:' + action_id);
	const { update, exec } = await db.operate(action_id, session_id, systemid);
	update('student_leave', {
		leave_num: message.leave_num,
		productid: message.productid
	}, {
			auditor_status: '1',
			leave_content: message.leave_content,
			reviewer: message.reviewer
		});
	const ret = await exec();
	return {
		data: ret
	};
}
